<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function (Request $request) {
	return redirect('login_view');
});

Route::get('/login_view', function (Request $request) {
	if(!empty(session('username'))){
        return redirect('/dashboard');
    }
    return view('login', ['type' => $request->get('type')]);
});

Route::get('/sign_in', function (Request $request) {
    return view('sign_in');
});

Route::get('/welcome', function (Request $request) {
	return view('welcome', ['username' => $request->username]);
});

// 登录
Route::post('/login', 'App\Http\Controllers\LoginController@login')->name('login');
// 注册
Route::post('/registered', 'App\Http\Controllers\LoginController@register');
// 退出
Route::post('/logout', 'App\Http\Controllers\LoginController@logout');
// 预约签到
Route::post('/reserve_singn', 'App\Http\Controllers\SingnInController@SingnIn');

Route::middleware('islogin')->get('/dashboard', 'App\Http\Controllers\ReserveController@dashboard');

Route::middleware('islogin')->get('/reserve', 'App\Http\Controllers\ReserveController@reserve');

Route::middleware('islogin')->any('/add_reserve', 'App\Http\Controllers\ReserveController@add_reserve');

Route::middleware('islogin')->post('/cancel', 'App\Http\Controllers\ReserveController@cancel');


